

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/egg.png">
  <link rel="icon" href="/img/egg.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="十一的蛋炒饭">
  <meta name="keywords" content="">
  
    <meta name="description" content="前端基础学习1 | Web、Html、CSS1、Web 基础知识1Web （www World Wide Web），全球广域网，也称万维网，能够通过浏览器访问的网站    Web网站的工作流程  1Web标准，也称为网页标准，由一些列的标准组成，大部分由W3C（World Wide Web Consortium，万维网联盟）负责制定。  Web标准由三个部分组成：  HTML：负责网页的结构（页面">
<meta property="og:type" content="article">
<meta property="og:title" content="前端基础学习1 | Web、HTML、CSS">
<meta property="og:url" content="http://example.com/2024/03/05/%E5%89%8D%E7%AB%AF%E5%9F%BA%E7%A1%80%E5%AD%A6%E4%B9%A01-Web%E3%80%81HTML%E3%80%81CSS/index.html">
<meta property="og:site_name" content="十一的蛋炒饭的博客">
<meta property="og:description" content="前端基础学习1 | Web、Html、CSS1、Web 基础知识1Web （www World Wide Web），全球广域网，也称万维网，能够通过浏览器访问的网站    Web网站的工作流程  1Web标准，也称为网页标准，由一些列的标准组成，大部分由W3C（World Wide Web Consortium，万维网联盟）负责制定。  Web标准由三个部分组成：  HTML：负责网页的结构（页面">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403050413319.png">
<meta property="og:image" content="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403050558044.png">
<meta property="og:image" content="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403050527599.png">
<meta property="article:published_time" content="2024-03-04T22:00:00.000Z">
<meta property="article:modified_time" content="2024-03-04T22:02:08.759Z">
<meta property="article:author" content="十一的蛋炒饭">
<meta property="article:tag" content="前端">
<meta property="article:tag" content="HTML">
<meta property="article:tag" content="CSS">
<meta property="article:tag" content="Web">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403050413319.png">
  
  
  
  <title>前端基础学习1 | Web、HTML、CSS - 十一的蛋炒饭的博客</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.7","typing":{"enable":true,"typeSpeed":60,"cursorChar":"","loop":false,"scope":["home"]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":"§"},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 7.1.1"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>十一的蛋炒饭 的博客</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/" target="_self">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/" target="_self">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/" target="_self">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/" target="_self">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/" target="_self">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/win7.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle">前端基础学习1 | Web、HTML、CSS</span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2024-03-05 06:00" pubdate>
          2024年3月5日 早上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          1.9k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          17 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar category-bar" style="margin-right: -1rem">
    





<div class="category-list">
  
  
    
    
    
    <div class="category row nomargin-x">
      <a class="category-item 
          list-group-item category-item-action col-10 col-md-11 col-xm-11" title="前端学习"
        id="heading-25cd04937610db1d37f83d7dae7e7e5d" role="tab" data-toggle="collapse" href="#collapse-25cd04937610db1d37f83d7dae7e7e5d"
        aria-expanded="true"
      >
        前端学习
        <span class="list-group-count">(3)</span>
        <i class="iconfont icon-arrowright"></i>
      </a>
      
      <div class="category-collapse collapse show" id="collapse-25cd04937610db1d37f83d7dae7e7e5d"
           role="tabpanel" aria-labelledby="heading-25cd04937610db1d37f83d7dae7e7e5d">
        
        
          
  <div class="category-post-list">
    
    
      
      
        <a href="/2024/03/05/%E5%89%8D%E7%AB%AF%E5%9F%BA%E7%A1%80%E5%AD%A6%E4%B9%A01-Web%E3%80%81HTML%E3%80%81CSS/" title="前端基础学习1 | Web、HTML、CSS"
           class="list-group-item list-group-item-action
           active">
          <span class="category-post">前端基础学习1 | Web、HTML、CSS</span>
        </a>
      
    
      
      
        <a href="/2024/03/05/%E5%89%8D%E7%AB%AF%E5%9F%BA%E7%A1%80%E5%AD%A6%E4%B9%A02-JavaScript%E5%9F%BA%E7%A1%80%E8%AF%AD%E6%B3%95%E3%80%81%E5%87%BD%E6%95%B0%E3%80%81%E5%AF%B9%E8%B1%A1%E3%80%81%E4%BA%8B%E4%BB%B6%E7%9B%91%E5%90%AC/" title="前端基础学习2 | JavaScript基础语法、函数、对象、事件监听"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">前端基础学习2 | JavaScript基础语法、函数、对象、事件监听</span>
        </a>
      
    
      
      
        <a href="/2024/03/06/%E5%89%8D%E7%AB%AF%E5%9F%BA%E7%A1%80%E5%AD%A6%E4%B9%A03-AJAX%E3%80%81Axios/" title="前端基础学习3 | AJAX、Axios"
           class="list-group-item list-group-item-action
           ">
          <span class="category-post">前端基础学习3 | AJAX、Axios</span>
        </a>
      
    
  </div>

        
      </div>
    </div>
  
</div>


  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">前端基础学习1 | Web、HTML、CSS</h1>
            
              <p id="updated-time" class="note note-info" style="display: none">
                
                  
                    本文最后更新于 2024-03-05T06:02:08+08:00
                  
                  

                
              </p>
            
            
              <div class="markdown-body">
                
                <h1 id="前端基础学习1-Web、Html、CSS"><a href="#前端基础学习1-Web、Html、CSS" class="headerlink" title="前端基础学习1 | Web、Html、CSS"></a>前端基础学习1 | Web、Html、CSS</h1><h2 id="1、Web-基础知识"><a href="#1、Web-基础知识" class="headerlink" title="1、Web 基础知识"></a>1、Web 基础知识</h2><figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-attribute">Web</span> （www World Wide Web），全球广域网，也称万维网，能够通过浏览器访问的网站<br></code></pre></td></tr></table></figure>



<p>Web网站的工作流程</p>
<p><img src="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403050413319.png" srcset="/img/loading.gif" lazyload alt="image-20240305041313234"></p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs">Web标准，也称为网页标准，由一些列的标准组成，大部分由W3C（World Wide Web Consortium，万维网联盟）负责制定。<br></code></pre></td></tr></table></figure>

<p>Web标准由三个部分组成：</p>
<ul>
<li>HTML：负责网页的<code>结构</code>（页面元素和内容）</li>
<li>CSS：负责网页的<code>表现</code>（页面元素的外观、位置等页面样式，如：颜色、大小等）</li>
<li>JavaScript：负责网页的<code>行为</code>（交互效果）</li>
</ul>
<h2 id="2、HTML-基础知识"><a href="#2、HTML-基础知识" class="headerlink" title="2、HTML 基础知识"></a>2、HTML 基础知识</h2><h3 id="2-1-什么是HTML"><a href="#2-1-什么是HTML" class="headerlink" title="2.1 什么是HTML"></a>2.1 什么是HTML</h3><p><strong>HTML（Hyper Text Markup Language）：超文本标记语言。</strong></p>
<ul>
<li>超文本，指超越文本限制，比普通文本更强大，除了文字信息外还可以定义图片、音频和视频等内容。</li>
<li>标记语言，指由标签构成的语言<ul>
<li>HTML标签都是预先定义好的，例如：<code>&lt;a&gt;</code> 表示超链接，<code>&lt;img&gt;</code> 展示图片。</li>
<li>HTML代码可以直接在浏览器中运行，HTML标签由浏览器解析。</li>
</ul>
</li>
</ul>
<p>HTML文件后缀都为<code>.html</code></p>
<p><strong>HTML代码的特点：</strong></p>
<ul>
<li>HTML标签不区分大小写（一般都用全小写）</li>
<li>HTML标签属性值单双引号都可以</li>
<li>HTML语法比较松散</li>
<li>HTML无法直接识别多个空格，通常用<code>&amp;nbsp; </code>这一连串的符号表示空格。</li>
</ul>
<p>HTML代码注释方式：<code>&lt;!--注释内容--&gt;</code></p>
<p>标准的HTML代码格式：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-comment">&lt;!-- 声明文档类型为 HTML --&gt;</span><br>&lt;! DOCTYPE html&gt;<br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>        <span class="hljs-comment">&lt;!-- 设置该部分内容字符集为 UTF-8，以便兼容中文 --&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>        <span class="hljs-comment">&lt;!-- 设置浏览器兼容性--&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">http-equiv</span>=<span class="hljs-string">&quot;X-UA-Compatible&quot;</span> <span class="hljs-attr">content</span>=<span class="hljs-string">&quot;IE=edge&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;viewport&quot;</span> <span class="hljs-attr">content</span>=<span class="hljs-string">&quot;width=device-width, initial-scale=1.0&quot;</span>&gt;</span><br>        <span class="hljs-comment">&lt;!-- 网站标题 --&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>网页标题<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>



<h3 id="2-2-HTML常用标签"><a href="#2-2-HTML常用标签" class="headerlink" title="2.2 HTML常用标签"></a>2.2 HTML常用标签</h3><p>相关链接：<a target="_blank" rel="noopener" href="https://www.w3school.com.cn/tags/index.asp">HTML 标签参考手册 (w3school.com.cn)</a></p>
<ol>
<li>图片标签：<code>&lt;img src=&quot;&quot; width=&quot;&quot; height=&quot;&quot;&gt;&lt;/img&gt;</code></li>
<li>标题标签：<code>&lt;h1&gt; 、&lt;h2&gt; ... &lt;h6&gt; </code></li>
<li>水平线标签：<code>&lt;hr&gt;</code></li>
<li>行内标签：<code>&lt;span&gt;</code></li>
<li>超链接标签（跳转网页）<code>&lt;a href=&quot;跳转链接&quot; target=&quot;跳转方式&quot;&gt;显示文字&lt;/a&gt;</code><ul>
<li>跳转方式主要有两种：<code>__self</code> 在当前页面跳转（默认值），<code>_blank</code>重新打开一个页面并跳转。</li>
</ul>
</li>
<li>视频标签：<code>&lt;video&gt;</code><ul>
<li>src ：规定视频的 url</li>
<li>controls：显示播放控件</li>
<li>width：播放器的宽度</li>
<li>height：播放器的高度</li>
</ul>
</li>
<li>音频标签：<code>&lt;audio&gt;</code><ul>
<li>src：规定音频的 url</li>
<li>controls：显示播放控件</li>
</ul>
</li>
<li>段落标签 <code>&lt;p&gt;</code></li>
<li>文本加粗标签：<code>&lt;b&gt; / &lt;strong&gt;</code></li>
<li>换行标签：<code>&lt;br&gt;</code></li>
<li>布局标签：<code>&lt;div&gt;</code> 和 <code>&lt;span&gt;</code><ul>
<li><code>&lt;div&gt;</code>又称作空标签，其特点有：<ul>
<li>独占整行，一行只显示一个</li>
<li>宽度默认是父元素的宽度，高度默认由内容撑开</li>
<li>可设置宽高（width和height）</li>
</ul>
</li>
<li><code>&lt;span&gt;</code> 即行内标签，其特点有：<ul>
<li>不占行，一行可显示多个</li>
<li>宽度和高度默认由内容撑开</li>
<li>不可以设置宽高（width和height）</li>
</ul>
</li>
</ul>
</li>
<li>表格标签: <code>&lt;table&gt;</code></li>
</ol>
<table>
<thead>
<tr>
<th>标签</th>
<th>描述</th>
<th>属性&#x2F;备注</th>
</tr>
</thead>
<tbody><tr>
<td><code>&lt;table&gt;</code></td>
<td>定义表格整体，可包括多个<code>&lt;tr&gt;</code></td>
<td>border: 规定表格边框的宽度。width: 规定表格的宽度。cellspacing：规定单元之间的空间。</td>
</tr>
<tr>
<td><code>&lt;tr&gt;</code></td>
<td>表格的行，可包括多个<code>&lt;td&gt;</code></td>
<td></td>
</tr>
<tr>
<td><code>&lt;td&gt;</code></td>
<td>普通单元格，可包括内容</td>
<td>若是表头单元格，可替换为 <code>&lt;th&gt;</code></td>
</tr>
</tbody></table>
<ol start="13">
<li><p><strong>表单标签：<code>&lt;form&gt;</code>（最重要的）</strong> </p>
<ul>
<li><p>在网页中表单标签主要负责数据采集，比如注册、登录等。</p>
</li>
<li><p>常用表单项标签</p>
<ul>
<li><code>&lt;input&gt;</code>：定义表单项，通过 type 属性控制输入形式</li>
<li><code>&lt;select&gt;</code>： 定义下拉列表</li>
<li><code>&lt;textarea&gt;</code>： 定义文本域</li>
</ul>
</li>
<li><p>属性</p>
<ul>
<li><code>action</code>：规定表单提交的位置</li>
<li><code>method</code>：规定用于发送表单数据的方式，GET（默认）、POST等</li>
</ul>
</li>
<li><p>登录案例</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">action</span>=<span class="hljs-string">&quot;user/login&quot;</span> <span class="hljs-attr">method</span>=<span class="hljs-string">&quot;post&quot;</span>&gt;</span><br>    用户名: <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text&quot;</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;username&quot;</span>&gt;</span><br>    密码: <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;password&quot;</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;password&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;submit&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;登录&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>提交表单时 GET 和 POST的区别：</p>
<ul>
<li>GET：在地址栏后拼接表单数据，如：?username&#x3D;”uni”&amp;password&#x3D;”123”, 地址栏长度有限制，是method属性的默认值</li>
<li>POST：在消息体（请求体）中传递信息，参数大小无限制。</li>
</ul>
</li>
</ul>
<p><img src="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403050558044.png" srcset="/img/loading.gif" lazyload alt="image-20240305055821941"></p>
</li>
</ol>
<h3 id="2-3-HTML-标签属性值"><a href="#2-3-HTML-标签属性值" class="headerlink" title="2.3 HTML 标签属性值"></a>2.3 HTML 标签属性值</h3><p>HTML每个标签都可以设置多个属性值，例如之前的<code>&lt;img&gt;</code>标签可设置src、width和height。</p>
<p>除此之外，最重要的是每个HTML标签都可以设置 <code>id</code> 、 <code>name</code>和&#96;&#96;class&#96; ，这将用来区分不同的HTML标签。</p>
<p>后面的&#96;&#96;CSS<code>和 </code>JavaScript<code>在选择HTML标签时可通过</code>id<code> 选取一个标签，或者通过</code>class&#96; 选取一类标签。</p>
<h2 id="3、CSS-基础知识"><a href="#3、CSS-基础知识" class="headerlink" title="3、CSS 基础知识"></a>3、CSS 基础知识</h2><p><strong>CSS（Cascading Style Sheet）：层叠样式表，用于控制页面的样式（表现）。</strong></p>
<p>相关链接：<a target="_blank" rel="noopener" href="https://www.w3school.com.cn/cssref/index.asp">CSS 参考手册 (w3school.com.cn)</a></p>
<h3 id="3-1-如何使用-CSS"><a href="#3-1-如何使用-CSS" class="headerlink" title="3.1 如何使用 CSS"></a>3.1 如何使用 CSS</h3><p>CSS引入方式：</p>
<ol>
<li><p>行内样式：写在标签的 style属性中（不推荐）。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;font-size:1.5em;&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>内嵌样式：写在 style标签中（可写在页面任何位置，但通常写在head标签中）。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><span class="language-css"></span><br><span class="language-css">    <span class="hljs-selector-tag">h1</span>&#123;</span><br><span class="language-css">        <span class="hljs-attribute">font-size</span>: <span class="hljs-number">1.5em</span>;</span><br><span class="language-css">    &#125;</span><br><span class="language-css"></span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>外联样式：写在一个单独的<code>.css</code> 文件中（需要通过 link标签在HTML网页中引入）。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-comment">/* style.css */</span><br><span class="hljs-selector-tag">h1</span>&#123;<br>	<span class="hljs-attribute">font-size</span>: <span class="hljs-number">1.5em</span><br>&#125;<br></code></pre></td></tr></table></figure>

<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-comment">&lt;!-- index.html --&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;css/style.css&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">link</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br></code></pre></td></tr></table></figure></li>
</ol>
<h3 id="3-2-CSS设置颜色"><a href="#3-2-CSS设置颜色" class="headerlink" title="3.2 CSS设置颜色"></a>3.2 CSS设置颜色</h3><p>HTML大部分标签支持CSS通过 <code>color</code> 属性的值来设置标签元素的颜色，通常由三个数字表示，分别表示红，黄，蓝颜色的深度，<code>rgb(0,0,0) </code>表示黑色，<code>rgb(255,255,255)</code>表示白色，数字最大为255，为方便设置，可直接用六位的16进制数表示，比如<code>#0AFF1C</code>就表示为<code>rgb(10,255,28)</code>，设置出来的颜色都是绿色：</p>
<p style="color:rgb(10,255,28)">第一种方式（绿色）</p>
<p style="color:#0AFF1C">第二种方式（还是绿色）</p>

<h3 id="3-3-CSS选择器"><a href="#3-3-CSS选择器" class="headerlink" title="3.3 CSS选择器"></a>3.3 CSS选择器</h3><p>CSS所设置的样式都是通过HTML标签元素来呈现的。</p>
<p>CSS选择器指用来选取所要设置样式的元素（标签）。</p>
<ol>
<li>元素选择器 <code>h1&#123;&#125;</code></li>
<li>id选择器 <code>#username &#123;&#125; </code></li>
<li>类选择器 <code>.list&#123;&#125;</code></li>
</ol>
<p>三个选择器的优先级顺序：<code>id选择器 &gt; 类选择器 &gt; 元素选择器</code></p>
<p>上述优先级的意思是，当同一个标签被设置重复属性的情况下，按顺序来遵循唯一的样式。</p>
<h3 id="3-4-CSS常用属性"><a href="#3-4-CSS常用属性" class="headerlink" title="3.4 CSS常用属性"></a>3.4 CSS常用属性</h3><p>相关链接：<a target="_blank" rel="noopener" href="https://www.w3school.com.cn/cssref/index.asp">CSS 属性大全 (w3school.com.cn)</a></p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-number">1</span>. <span class="hljs-attribute">color</span>: <span class="hljs-number">#FFFFFF</span>; 定义文本颜色，例如<span class="hljs-selector-id">#FFFFFF</span>表示白色<br><br><span class="hljs-number">2</span>. <span class="hljs-attribute">text-decoration</span>: underline; 修饰文本，例如underline表示添加下划线<br><br><span class="hljs-number">3</span>. <span class="hljs-attribute">line-height</span>: <span class="hljs-number">20px</span>;  设置行高为<span class="hljs-number">20</span>个像素点<br><br><span class="hljs-number">4</span>. <span class="hljs-attribute">text-indent</span>: <span class="hljs-number">2em</span>;   通常用于<span class="hljs-selector-tag">p</span>标签，表示行内容的缩进为<span class="hljs-number">2</span>个字符<br><br><span class="hljs-number">5</span>. <span class="hljs-attribute">text-align</span>: left;   规定标签中的文本水平对其方式为左对齐<br><br><span class="hljs-number">6</span>. <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span> auto;     让标签外边距两边各占一半，正常情况下，值有四个，分别是上 右 下 左<br></code></pre></td></tr></table></figure>





<h3 id="3-5-CSS-盒子模型"><a href="#3-5-CSS-盒子模型" class="headerlink" title="3.5 CSS 盒子模型"></a>3.5 CSS 盒子模型</h3><p>CSS对于每一个块标签都有盒子布局的概念。</p>
<p>盒子：页面中所有的标签都可以看成是一个盒子，由盒子将页面中的元素包含在一个矩形区域内，通过盒子的视角更方便的进行页面布局。</p>
<p>盒子模型从内到外组成有：</p>
<ul>
<li>content：内容区域</li>
<li>padding：内边距区域</li>
<li>border：边框区域</li>
<li>margin：外边距区域</li>
</ul>
<p><img src="https://uni-pic-bed.oss-cn-hangzhou.aliyuncs.com/blog2024/202403050527599.png" srcset="/img/loading.gif" lazyload alt="image-20240305052733485"></p>
<h1 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h1><p><a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1m84y1w7Tb">https://www.bilibili.com/video/BV1m84y1w7Tb</a></p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A0/" class="category-chain-item">前端学习</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/%E5%89%8D%E7%AB%AF/" class="print-no-link">#前端</a>
      
        <a href="/tags/HTML/" class="print-no-link">#HTML</a>
      
        <a href="/tags/CSS/" class="print-no-link">#CSS</a>
      
        <a href="/tags/Web/" class="print-no-link">#Web</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>前端基础学习1 | Web、HTML、CSS</div>
      <div>http://example.com/2024/03/05/前端基础学习1-Web、HTML、CSS/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>十一的蛋炒饭</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2024年3月5日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2024/03/05/%E5%89%8D%E7%AB%AF%E5%9F%BA%E7%A1%80%E5%AD%A6%E4%B9%A02-JavaScript%E5%9F%BA%E7%A1%80%E8%AF%AD%E6%B3%95%E3%80%81%E5%87%BD%E6%95%B0%E3%80%81%E5%AF%B9%E8%B1%A1%E3%80%81%E4%BA%8B%E4%BB%B6%E7%9B%91%E5%90%AC/" title="前端基础学习2 | JavaScript基础语法、函数、对象、事件监听">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">前端基础学习2 | JavaScript基础语法、函数、对象、事件监听</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2024/03/05/Java%E5%9F%BA%E7%A1%80%E5%AD%A6%E4%B9%A02-%E5%85%B3%E9%94%AE%E5%AD%97%E3%80%81%E5%AD%97%E9%9D%A2%E9%87%8F%E3%80%81%E6%A0%87%E8%AF%86%E7%AC%A6%E3%80%81%E5%8F%98%E9%87%8F%E3%80%81%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B/" title="Java基础学习2 | 关键字、字面量、标识符、变量、数据类型">
                        <span class="hidden-mobile">Java基础学习2 | 关键字、字面量、标识符、变量、数据类型</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>博客网站基于Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>主题Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.4/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>





  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  var relativeDate = function() {
    var updatedTime = document.getElementById('updated-time');
    if (updatedTime) {
      var text = updatedTime.textContent;
      var reg = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:Z|[+-]\d{2}:\d{2})/;
      var matchs = text.match(reg);
      if (matchs) {
        var relativeTime = moment(matchs[0]).fromNow();
        updatedTime.textContent = text.replace(reg, relativeTime);
      }
      updatedTime.style.display = '';
    }
  };
  Fluid.utils.createScript('https://lib.baomitu.com/moment.js/2.29.4/moment.min.js', function() {
    if (!'zh-cn'.startsWith('en')) {
      Fluid.utils.createScript('https://lib.baomitu.com/moment.js/2.29.4/locale/zh-cn.min.js', function() {
        relativeDate();
      });
    } else {
      relativeDate();
    }
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.20.1/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
